<script setup lang="ts">
import { onMounted } from 'vue';
import { useGlobalStore } from './store';

const store = useGlobalStore();

onMounted(() => {
  console.log('App onMounted')
  const loginJson = localStorage.getItem('token');
  store.token = '1';
  store.tokenExpired = 1;
  console.log('store');
          
  if (loginJson) {
    const loginData = JSON.parse(loginJson);
    console.log('loginData', loginData);
    console.log(loginData.expired, Math.floor(Date.now() / 1000));
    
    if (loginData.expired > Math.floor(Date.now() / 1000)) {
        store.token = loginData.token;
        store.tokenExpired = loginData.expired
    }
  }
})
</script>

<template>
  <div class="app-container">
    <router-view />
  </div>
</template>

<style scoped>
.app-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}
</style>
